package com.whq.thrift.api.web.admin.db.verify;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

public interface MerchantKeyMapper {
	@Select("select * from t_merchant_key where merchant_name=#{merchantName}")
	@Results(
		value = {
			@Result(property="merchantName", column="merchant_name"),
			@Result(property="publicKey", column="public_key"),
			@Result(property="insertTime", column="insert_time"),
			@Result(property="signatureKey", column="signature_key")
		}
	)
	public MerchantKey getRecordByKey(@Param("merchantName") String merchantName);
	
	@Insert("INSERT INTO t_merchant_key "
			+ " (merchant_name, public_key, insert_time, signature_key) "
			+ " VALUES "
			+ " (#{merchantName}, #{publicKey}, #{insertTime}, #{signatureKey})")
    public void addRecord(MerchantKey MerchantKey);
    
	@SelectProvider(type = MerchantKeySqlProvider.class, method = "getSelectRecordsSql")
	@Results(
			value = {
					@Result(property="merchantName", column="merchant_name"),
					@Result(property="publicKey", column="public_key"),
					@Result(property="insertTime", column="insert_time"),
					@Result(property="signatureKey", column="signature_key")
			}
		)
    public List<MerchantKey> findRecordsByMap(Map<String, Object> whereParams);
	
	@SelectProvider(type = MerchantKeySqlProvider.class, method = "getSelectCountSql")
    public int findRecordsCount(Map<String, Object> whereParams);
	
	@UpdateProvider(type = MerchantKeySqlProvider.class, method = "getUpdateSql")
	public void updRecord(MerchantKey merchantKey);
	
	@Delete("delete from t_merchant_key where merchant_name=#{merchantName}")
	public void delRecord(@Param("merchantName") String merchantName);
}
